/*
* 权限指令
*/

import Vue from 'vue'

Vue.directive('permission', (el, binding, vnode) => {
  console.log('binding', binding)
  const { value } = binding
  const roles = [1, 2, 3]
  if (value) {
    const hasPermission = roles.includes(value)
    if (!hasPermission) {
      console.log(el)
      el.parentNode && el.parentNode.removeChild(el)
    }
  } else {
    throw new Error(`not value`)
  }
})
